home *** CD-ROM | disk | FTP | other *** search
- Path: news.pi.se!usenet
- From: delenn@babcom.space.com (Satai Delenn)
- Newsgroups: comp.lang.c++
- Subject: Pointers HELP!!!!
- Date: Tue, 23 Jan 1996 22:23:35 GMT
- Message-ID: <31055e1d.1020193@news.pi.se>
- NNTP-Posting-Host: d406.sth.pi.se
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: Forte Agent .99c/16.141
-
- Hia!
-
- What I want to do is to pass a pointer to a member function to another
- object, which later will call this function thru this pointer.
-
- What I did:
-
- ////////////////////////////////////////////////////
- typedef void(*PFUNC)(int);
- ////////////////////////////////////////////////////
- class A
- {
- public:
- void callback(int error) {
- /* Something */;
- }
-
- B* pB;
- public:
- A() {
- pB = new B(A::callback);
- };
- ~A() {
- delete pB;
- };
- };
- ////////////////////////////////////////////////////
- class B
- {
- public:
- PFUNC m_callback;
- public:
- B(PFUNC callback) {
- m_callback = callback;
- *m_callback(10);
- }
- ~B(){};
- };
- ////////////////////////////////////////////////////
-
- I know this doesnt work, so please ne1 help me out here.
-
- // thomas@mediamatic.se
-
-
-
-